<div class="panel panel-default">
<div class=" panel-heading">Work [ <?=$work->name?> ]</div>
<div class="panel-body">

<a class="btn btn-warning btn-sm pull-right" href="<?=site_url('catalog/works')?>"><i class="glyphicon glyphicon-arrow-left"></i><?=nbs(1)?> back to list</a>
</div>
</div>

<div class="row">
	
	<div class="col-md-6">
		<div class="panel panel-default">
		<div class="panel-heading">Work's informations <i class="glyphicon glyphicon-info-sign"></i></div>
			<div class="panel-body">

			<h4>Activity <?php if($work->active == '1' ){?><span class="label label-success">Active</span><?php }else{?><span class="label label-danger">Blocked</span><?php }?></h4>
			<hr>
	
			<h4>Name: <?=$work->name?></h4>
			<hr>
			<h4>Customer: <?=$work->client_id?></h4>
			<hr>				
			<h4>Short description:</h4>
			<p><?=$work->description?></p>	
			<hr>
			<a class="btn btn-primary btn-sm pull-right" href="<?=site_url('catalog/works/edit')?>/<?=$work->id?>"><i class="glyphicon glyphicon-pencil"></i><?=nbs(1)?> edit</a>
			<a class="btn btn-danger btn-sm" href="<?=site_url('catalog/works/deleteWork')?>/<?=$work->id?>"><i class="glyphicon glyphicon-trash"></i> delete</a>
			</div>
		
	</div>
		<div class="panel panel-default">
			<div class="panel-heading">Work's Cover <i class="glyphicon glyphicon-picture"></i></div>
			<div class="panel-body">
				<?php if($cover !=NULL){?>
				 <a href="#" class="thumbnail">
				<img src="<?=base_url()?>../uploads/thumbs/<?=$cover->filename_s?>" alt="..." >
				</a>
				<?php }else{?>
				 <a href="#" class="thumbnail">
      <img src="<?=base_url()?>../uploads/thumb_default.jpg" alt="..." >
    </a>
		
				<?php }?>
			</div>
		</div>
	</div>
	
	<div class="col-md-6">
		<div class="panel panel-default">
		<div class="panel-heading">Work's photos <i class="glyphicon glyphicon-picture"></i></div>
			<div class="panel-body">
			<?php foreach ($photos as $p):?>
			
    <div class="thumbnail">
      <img src="<?=base_url()?>../uploads/thumbs/<?=$p->filename_s?>" alt="..." width="200" class="pull-left ">
       <div class="caption pull-right">
       <p><?php if($p->active==1){?><span class="label label-success">active</span><?php }else{?><span class="label label-danger">disabled</span><?php }?></p>
        <h5>Description</h5>
     
        <p><a href="#" class="btn btn-primary btn-sm" role="button"><i class="glyphicon glyphicon-pencil"></i></a> <button class="btn btn-danger btn-sm" role="button" onclick="deleteItem_2(<?=$p->id?>,'<?=$p->filename_s?>')"><i class="glyphicon glyphicon-trash"></i></button></p>
        <p><button class="btn btn-primary btn-xs" role="button" onclick="makeCover(<?=$p->id?>);" <?php if(isset($cover)){ if($p->id == $cover->id){?>disabled<?php }}?>>make as cover <i class="glyphicon glyphicon-picture"></i></button></p>
        <p>
         <button type="button" class="btn btn-primary btn-xs" onclick="position_up(<?=$p->id?>);" <?php if($p->position==1){?>disabled<?php }?>><i class="glyphicon glyphicon-circle-arrow-up"></i></button> 
				<?=$p->position?> 
		<button type="button" class="btn btn-primary btn-xs" onclick="position_down(<?=$p->id?>);" <?php if($lastPosition == $p->position){?>disabled<?php }?>><i class="glyphicon glyphicon-circle-arrow-down"></i></button>	
        </p>
       <form actions="" method="post" role="form" class="form-inline" id="position_up_<?=$p->id?>" enctype="multipart/form-data">			
				<input type="hidden" name="id" value="<?=$p->id?>">
				<input type="hidden" name="position" value="<?=$p->position?>">
				<input type="hidden" name="action" value="up">
			</form>
			<form actions="" method="post" role="form" class="form-inline" id="position_down_<?=$p->id?>" enctype="multipart/form-data">
				<input type="hidden" name="id" value="<?=$p->id?>">
				<input type="hidden" name="position" value="<?=$p->position?>">
				<input type="hidden" name="action" value="down">
			</form>
			<form actions="" method="post" role="form" class="form-inline" id="makeCover_<?=$p->id?>" enctype="multipart/form-data">
				<input type="hidden" name="id" value="<?=$p->id?>">
				<input type="hidden" name="action" value="cover">
			</form>
      </div>
   	<div class="clearfix"></div>
  </div>
			<?php endforeach;?>
			<hr>
			<a class="btn btn-primary btn-sm pull-right" href="<?=site_url('catalog/upload')?>/<?=$work->id?>"><i class="glyphicon glyphicon-plus-sign"></i><?=nbs(1)?> add photos</a>
			</div>
		
		</div>
	</div>
</div>

<div id="deleteItem" class="modal fade " tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">×</button>
					<h4 id="myModalLabel">Action:</h4>
				</div>
				<div class="modal-body">Would you like to delete this photo ?</div>
				<div class="modal-footer">
					
					
				</div>
			</div>
		</div>
	</div>
	